package xty.rabbitmq.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xty.rabbitmq.enums.RabbitMQQueue;
import xty.rabbitmq.producer.RabbitMQProducer;

import javax.annotation.Resource;

/**
 * Created by XieTianYi on 2020/2/17.
 *
 * @author XieTianYi
 */
@RestController
@RequestMapping("rabbitmq")
public class RabbitMQController {

    @Resource
    private RabbitMQProducer msgProducer;

    @RequestMapping("demo")
    public String demo() {

        for (int i = 0; i < 50; i++) {
            msgProducer.sendMsg(RabbitMQQueue.QUEUE_A.getExchange(), RabbitMQQueue.QUEUE_A.getRouteKey(), "次数：" + i);
        }
        return "已调用";
    }
}
